﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.Security.Cryptography;
using System.Net;
using System.Text;

namespace WuYuHotel.WX_AccToken
{
    public class HttpService
    {
        public static string Post(string xml, string url, bool isUseCert, int timeout)
        {


            System.GC.Collect();//垃圾回收，回收没有正常关闭的http连接

            string result = "";//返回结果

            byte[] PostData = Encoding.UTF8.GetBytes(xml);
            WebClient webClient = new WebClient();
            webClient.Headers.Add("Content-Type", "text/xml");
            try
            {
                byte[] ResponseData = webClient.UploadData(url, "POST", PostData);
                string SrcString = Encoding.UTF8.GetString(ResponseData);
                result = SrcString.Trim();
            }
            catch (Exception e)
            {

                throw new WxPayException(e.ToString());
            }
            return result;

        }



    }
}